from core.base import Base
from config.config import Config


def get_echo(pathparam):
    print("-------请求echo接口---------")
    baseobj.base_get(''.join(['echo/', pathparam]))
    return

def get_say(word):
    return get_normal('say', word)

def get_normal(method, word):
    print("--------------请求{}接口----------------".format(method))
    param = baseobj.generate_params(['word'], [word])
    baseobj.base_get('?'.join([method, param]))
    return

def get_search(word):       
    return get_normal('search', word)

def post_login(username, password):
    print("-------请求login接口-------")
    param = Base.generate_params(['username', 'passwd'], [username, password])
    baseobj.base_post('?'.join(['login', param]))
    return


GConfig = Config('/home/yuexl/hdfile/WorkSpace/python/Test/ApiTest/Practices/requests/config.yaml')

def request_search():
    get_echo("heihei")
    get_say("heiheia")
    get_search('golang')
    get_search('python')
    get_search('test')
    get_search('linux')
    post_login('heihei', '123asd')

if __name__ == '__main__':
    rootPath = GConfig.get_domain()
    baseobj = Base(rootPath)
    request_search()